//https://leetcode.cn/problems/longest-substring-without-repeating-characters/

class Solution {
public:
    int lengthOfLongestSubstring(string s) {
        int left = 0;
        unordered_set<char> sub;
        int len = INT_MIN;
        for (int right = 0; right < s.size(); right++) {
            while (sub.count(s[right])) {
                sub.erase(s[left]);
                left++;
            }
            sub.insert(s[right]);
            len = max(len, right - left + 1);

        }
        return (len == INT_MIN) ? 0 : len;
    }
};